from django.db import models

# Create your models here.
class AttributeType(models.Model):
    name = models.CharField(max_length=100, unique=True)
    defaultValue = models.TextField()
    
    def __unicode__(self):
        return (self.name)


class PersonType(models.Model):
    name = models.TextField()
    parent = models.ForeignKey('self', null=True, blank=True)
    attributes = models.ManyToManyField('PersonAttribute', null=True, blank=True)
    
    def __unicode__(self):
        return (self.name + u'[' + unicode(self.pk) + u']')

    
class PersonAttribute(models.Model):
    name = models.TextField()
    type = models.ForeignKey('AttributeType')
    types = models.ManyToManyField('PersonType', null=True, blank=True)

    def __unicode__(self):
        return (self.name + u'[' + unicode(self.pk) + u']')


class GroupType(models.Model):
    name = models.TextField()
    parent = models.ForeignKey('self', null=True, blank=True)
    attributes = models.ManyToManyField('GroupAttribute', null=True, blank=True)
    
    def __unicode__(self):
        return (self.name + u'[' + unicode(self.pk) + u']')

    
class GroupAttribute(models.Model):
    name = models.TextField()
    type = models.ForeignKey('AttributeType')
    types = models.ManyToManyField('GroupType', null=True, blank=True)

    def __unicode__(self):
        return (self.name + u'[' + unicode(self.pk) + u']')


class EventType(models.Model):
    name = models.TextField()
    parent = models.ForeignKey('self', null=True, blank=True)
    attributes = models.ManyToManyField('EventAttribute', null=True, blank=True)
    
    def __unicode__(self):
        return (self.name + u'[' + unicode(self.pk) + u']')

    
class EventAttribute(models.Model):
    name = models.TextField()
    type = models.ForeignKey('AttributeType')
    types = models.ManyToManyField('EventType', null=True, blank=True)

    def __unicode__(self):
        return (self.name + u'[' + unicode(self.pk) + u']')
